home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / hostname.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-10-06  |  909 b   |  48 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          hostname
  4. # Required-Start:
  5. # Required-Stop:
  6. # Default-Start:     S
  7. # Default-Stop:
  8. # Short-Description: Set hostname.
  9. # Description:
  10. ### END INIT INFO
  11.  
  12. PATH=/sbin:/bin
  13.  
  14. . /lib/init/vars.sh
  15. . /lib/lsb/init-functions
  16.  
  17. do_start () {
  18.     [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"
  19.  
  20.     # Keep current name if /etc/hostname is missing.
  21.     [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname)"
  22.  
  23.     # And set it to 'localhost' if no setting was found
  24.     [ -z "$HOSTNAME" ] && HOSTNAME=localhost
  25.  
  26.     [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname to '$HOSTNAME'"
  27.     hostname "$HOSTNAME"
  28.     ES=$?
  29.     [ "$VERBOSE" != no ] && log_action_end_msg $ES
  30. }
  31.  
  32. case "$1" in
  33.   start|"")
  34.     do_start
  35.     ;;
  36.   restart|reload|force-reload)
  37.     echo "Error: argument '$1' not supported" >&2
  38.     exit 3
  39.     ;;
  40.   stop)
  41.     # No-op
  42.     ;;
  43.   *)
  44.     echo "Usage: hostname.sh [start|stop]" >&2
  45.     exit 3
  46.     ;;
  47. esac
  48.